<template>
  <div>
    <el-dialog :title="title" :visible.sync="dialogFormVisible">
      <el-form :model="form">
        <el-form-item
          :label="v.title"
          :label-width="formLabelWidth"
          v-for="(v, i) in ruleList"
          :key="i"
        >
          <el-select
            v-model="form['pid']"
            v-if="v.field == 'pid'"
            placeholder="请选择父级分类"
          >
            <el-option
              v-for="(m, n) in v.options"
              :key="n"
              :label="m.label"
              :value="m.value"
            >
            </el-option>
          </el-select>
          <el-input
            placeholder="请输入分类昵称"
            v-if="v.field == 'title'"
            v-model="form['title']"
          >
          </el-input>

          <el-input
            placeholder="请输入分类字段英文"
            v-if="v.field == 'eng_title'"
            v-model="form['eng_title']"
          >
          </el-input>
          <el-input v-if="v.field == 'icon'" v-model="form['icon']"> </el-input>
          <el-radio-group v-model="form['type']" v-if="v.field == 'type'">
            <el-radio :label="0">系统</el-radio>
            <el-radio :label="3">其他</el-radio>
          </el-radio-group>
          <el-radio-group v-model="form['status']" v-if="v.field == 'status'">
            <el-radio :label="1">显示</el-radio>
            <el-radio :label="0">隐藏</el-radio>
          </el-radio-group>
          <el-input-number
            v-model="form['sort']"
            v-if="v.field == 'sort'"
            controls-position="right"
            :min="0"
          ></el-input-number>
        </el-form-item>
      </el-form>
      <div slot="footer" class="dialog-footer">
        <el-button @click="dialogFormVisible = false">取 消</el-button>
        <el-button type="primary" @click="submit">确 定</el-button>
      </div>
    </el-dialog>
  </div>
</template>

<script>
export default {
  props: ["dialogFormVisible", "form", "title", "ruleList"],
  data() {
    return {
      formLabelWidth: "120px",
    };
  },

  methods: {
    submit() {
      this.$emit("finish", this.form);
    },
  },
};
</script>
<style scoped></style>
